package src.ten;

import java.util.*;

public class MapText {

    public static void main(String[] args) {
        Map map = new HashMap();
        Emp emp = new Emp("001","张三");
        Emp emp1 = new Emp("005","李四");
        Emp emp2 = new Emp("004","王一");
        map.put(emp.getE_id(),emp.getE_name());
        map.put(emp1.getE_id(),emp1.getE_name());
        map.put(emp2.getE_id(),emp2.getE_name());
        Set set = map.keySet();
        Iterator iterator = set.iterator();
        System.out.println("HashMap类实现的Map集合，无序：");
        while (iterator.hasNext()){
            String next = (String) iterator.next();
            String o = (String) map.get(next);
            System.out.println(next+","+o);
        }
        System.out.println("treeMap实现的Map集合，把对象升序");
        TreeMap treeMap = new TreeMap();
        treeMap.putAll(map);
        Iterator iterator1 = treeMap.keySet().iterator();
        while (iterator1.hasNext()){
            String next = (String) iterator1.next();
            String o = (String) map.get(next);
            System.out.println(next+","+o);
        }
    }
}
